<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('薪资配置列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>项目名称：</label>
                                <input type="text" name="name" />
                            </li>
                            <input type="hidden" id="postId" name="postId" th:value="${postId}"/>
                            <li>
                                <label>项目类型：</label>
                                <select name="type" th:with="type=${@dict.getType('salary_allocation_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success"  onclick="add()"  shiro:hasPermission="salary:allocation:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="salary:allocation:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('salary:allocation:edit')}]];
        var removeFlag = [[${@permission.hasPermi('salary:allocation:remove')}]];
        var typeDatas = [[${@dict.getType('salary_allocation_type')}]];
        var ruleDatas = [[${@dict.getType('salary_allocation_rule')}]];
        var stateDatas = [[${@dict.getType('state')}]];
        var gradeDatas = [[${@dict.getType('salary_allocation_grade')}]];
        var prefix = ctx + "business/salaryallocation";

        $(function() {
            var options = {
                url: "/business/salaryallocation/salaryallocationDetaillist",
                createUrl: prefix + "/add/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "薪资配置",
                queryParams: queryParams,
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: '主键',
                    visible: true
                },
                {
                    field: 'name',
                    title: '项目名称'
                },
                {
                    field: 'type',
                    title: '项目类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field: 'rule',
                    title: '计算规则',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(ruleDatas, value);
                    }
                },
                {
                    field: 'money',
                    title: '涉及金额'
                },
                {
                    field: 'state',
                    title: '状态',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(stateDatas, value);
                    }
                },
                {
                    field: 'grade',
                    title: '岗位等级',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(gradeDatas, value);
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        function queryParams(params) {
            var search = $.table.queryParams(params);
            search.id = $("#postId").val();
            return search;
        }

        function add() {
            var postId =  $("#postId").val();
            $.operate.add(postId);
        }
    </script>
</body>
</html>